package grpc

import (
	"context"
	"travel-social-app/internal/models/dao"
	"travel-social-app/internal/models/services"
	user1 "travel-social-app/internal/protp/user"
)

type UserServer struct {
	user1.UnimplementedRegisterServerServer
}

// SayHello implements helloworld.GreeterServer
func (s *UserServer) Register(ctx context.Context, req *user1.RegisterReq) (*user1.RegisterResp, error) {
	user := dao.User{
		Name: req.Name,
		Pass: req.Pass,
	}
	err := services.CreateUser(user)
	if err != nil {
		return nil, err
	}
	resp := &user1.RegisterResp{
		Code: 0,
		Msg:  "",
	}
	return resp, nil
}
